import Vue from "vue"
import hmNotice from "./notice.vue"
const NoticeConstructor = Vue.extend(hmNotice)

let itemArr = []
let count = 0


//重新排位,需要  transition 
function Ranking() {
    itemArr = itemArr.filter(item => {
        return item.isRemove === false
    })
    itemArr.forEach((item, index) => {
        console.log(item)
        item.$el.style.top = 16 + index * 120 + "px"
        // item.$el.style.transform =  `translateY(${16+120*(index+1)}px)`
    })

    console.log(itemArr)
}

export {Ranking}

export default function notice(options) {


  
    /*
       options:{
            title:"xxx",
            message:"xxxx"
        }

        */

    //实例化组件
    const instance = new NoticeConstructor({
        data: options
    })

    itemArr.unshift(instance)

    //挂载
    instance.$mount() //渲染dom元素

    //手动挂载到body上
    document.body.appendChild(instance.$el)

    Ranking()

    return instance
}